<?php
/*
Template Name: Services
*/
?>
<?php get_header(); ?>
<div id="main" class="clearfix services-wrap">
<?php
// get custom post type ==> homepage-tabs
global $post;
	$args = array(
		'post_type'=>'services',
		'numberposts' => -1,
		'orderby' => 'ASC'
	);
	$services_posts = get_posts($args);
?>
<?php
// load code if there are tab posts
if($services_posts) {
// hold post title in array
$captions = array();
?>
        <ul class="tabs">
        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <li class="services-info">
    	<h1><span><?php the_title(); ?></span></h1>			
    	<?php the_content(); ?>    
        </li>
        <?php endwhile; ?>
    	<?php endif; ?>  
        <?php 
        // temp loop for tab links
        foreach($services_posts as $post) : setup_postdata($post);
        // tab counter
        $tabcount++;
        ?>
        <li><a href="#tab<?php echo $tabcount ?>"><?php the_post_thumbnail(''); ?><?php the_title(); ?></a></li>
        <?php endforeach; ?>
    	</ul>
        
        <div class="tab-container">
            <?php
            // start loop
            foreach($services_posts as $post) : setup_postdata($post);
            // post counter
            $postcount++;
            ?>	
       		<div id="tab<?php echo $postcount ?>" class="tab-content">
                <h2><?php the_title(); ?></h2>
                <?php the_content(' ') ?>
            </div>
            <!-- END tab -->
      		<?php endforeach; ?>  
        	</div>
        	<!-- END tab-container -->
            <div class="clear"></div>
<?php } wp_reset_postdata(); ?>
<?php get_footer(); ?>